{% extends "admin/base_site.html" %}
{% load i18n %}

{% block extrahead %}
    <script type="text/javascript" src="/admin/jsi18n/"></script>
    <script type="text/javascript" src="/static/js/time_actions.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            grappelli.initDateAndTimePicker();
        });
    </script>

    <script type="text/javascript">
        function options_toggle(id) {
            if ($('#' + id.split("_")[1] + '_' + id.split("_")[2]).is(':visible')) {
                $('#' + id).html('Show ' + id.split("_").slice(-2) );
            } else {
                $('#' + id).html('Hide ' + id.split("_").slice(-2));
            }
            $('#' + id.split("_")[1] + '_' + id.split("_")[2]).toggle('fast');
        }
    </script>
{% endblock %}


{% block breadcrumbs %}
  <div id="breadcrumbs"> 
  <a href="{% url admin:index %}"> 
   Home
  </a>
  &rsaquo; 
  <a href="{% url admin:app_list 'discipline' %}"> 
   Discipline
  </a> 
  &rsaquo; 
  <a href="{% url admin:discipline_studentdiscipline_changelist %}"> 
   Student disciplines
  </a> 
  &rsaquo; 
  Student disciplines statistics
  </div> 
{% endblock %}

{% block content_title %}
    <h1>Discipline Reports</h1>
{% endblock %}

{% block content %}
    <form action="" method="post" style="width:850px;">
        <fieldset>
            {{ form.non_field_errors  }}
            <table>
                <tr><td>
                    <a href="#" id="toggle_time_options" onclick='options_toggle(id)'>Show time options</a>
                    <div id="time_options" style="display: none">
                        {{ form.this_year.label }} {{ form.this_year }} {{ form.this_year.errors }}
                        <br/> {{ form.all_years.label }} {{ form.all_years }} {{ form.all_years.errors }}
                        <br/> {{ form.date_begin.label }} {{ form.date_begin }} {{ form.date_begin.errors }}
                        <br/> {{ form.date_end.label }} {{ form.date_end }} {{ form.date_end.errors }}
                        <br/> {{ form.marking_period.label }} {{ form.marking_period }} {{ form.marking_period.errors }}
                    </div>
                </td></tr><tr><td>
                    {{ form.include_deleted.label }} {{ form.include_deleted }} {{ form.include_deleted.errors }}
                </td></tr><tr><td>
                    {{ form.order_by.label }} {{ form.order_by }} {{ form.order_by.errors }}
                </td></tr><tr><td>
                    <span style="font-style: italic;"> Filter reports by students who have at least these many Actions or Infractions:</span>
                    <div>
                        {{ form.action.label }} {{ form.action }} {{ form.action.errors }}
                    </div>
                    <div>
                        Minimum: {{ form.minimum_action }} {{ form.minimum_action.errors }}
                    </div>
                    <div>
                        {{ form.infraction.label }} {{ form.infraction }} {{ form.infraction.errors }}
                        Minimum: {{ form.minimum_infraction }} {{ form.minimum_infraction.errors }}
                    </div>
                </td></tr>
            </table>
            <input type="submit" name="student" value="By Student Report" /> 
            <input type="submit" name="aggr" value="Aggregate Report" />
        </fieldset>
        <br/>
        <fieldset>
            <legend>Merit Levels (recent discipline awards)</legend>
            &nbsp;
            {{ merit_form.non_field_errors  }}
            {{ merit_form.start_date.label }} {{ merit_form.start_date }} {{ merit_form.start_date.errors }} &nbsp;&nbsp;&nbsp;&nbsp&nbsp
            {{ merit_form.end_date.label }} {{ merit_form.end_date }} {{ merit_form.end_date.errors }}
            <table>
                <tr>
                    <th colspan="2">Merit levels - Number of Discipline issues for level </th>
                </tr>
                <tr>
                    <td>{{ merit_form.level_one.label }}</td>
                    <td>{{ merit_form.level_one }} {{ merit_form.level_one.errors }}</td>
                </tr>
                <tr>
                    <td>{{ merit_form.level_two.label }}</td>
                    <td>{{ merit_form.level_two }} {{ merit_form.level_two.errors }}</td>
                </tr>
                <tr>
                    <td>{{ merit_form.level_three.label }}</td>
                    <td>{{ merit_form.level_three }} {{ merit_form.level_three.errors }}</td>
                </tr>
                <tr>
                    <td>{{ merit_form.level_four.label }}</td>
                    <td>{{ merit_form.level_four }} {{ merit_form.level_four.errors }}</td>
                </tr>
                <tr>
                    <td>{{ merit_form.sort_by.label }}</td>
                    <td>{{ merit_form.sort_by }} {{ merit_form.sort_by.errors }}</td>
                </tr>
            </table>
            <input type="submit" name="merit"/>
            <br/>
            {% if perms.adminstration.change_configuration %}
                <a href="/admin/administration/configuration/?q=discipline">Edit Defaults</a>
            {% endif %}
        </fieldset>
    </form>
{% endblock %}